<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"
    />
    <title>代理模式</title>
</head>

<body>
    <h2>书籍：《javascript设计模式与开发实践》</h2>
    <h3>在四月一个晴朗的早晨，小明遇见了他的百分百女孩，我们暂且称呼小明的女神为 A。两天之后，小明决定给 A送一束花来表白。刚好小明打听到 A和他有一个共同的朋友 B，于是内向的小明决定让 B来代替自己完成送花这件事情</h3>
    <script type="text/javascript">
        function Flow() {
            this.name = 'flow'
        }
        var xiaoming = {
            sendFlow: function (target) {
                var newFlow = new Flow()
                target.proxysendFlow(newFlow)
            }
        }
        var A = {
            name:'a',
            receiveFlow: function (flow) {
                console.log(this.name + ' 收到花 ' + flow.name)
            }
        }
        var B = {
            name:'b',
            proxysendFlow:function (flow) {
                A.receiveFlow(flow)
            }
        }
        xiaoming.sendFlow(B)
    </script>

</body>

</html>